package com.kevin.action.back;

import javax.servlet.http.HttpServletRequest;

import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.View;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.By;
import org.nutz.mvc.annotation.Filters;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.nutz.mvc.filter.CheckSession;
import org.nutz.mvc.view.JspView;

import com.kevin.model.Message;
import com.kevin.service.MessageService;
import com.kevin.validate.Errors;


/**
 * 
  * @ClassName: MessageBackAction 
  * @Description: 留言后台模块
  * @author 吕凯
  * @date 2012-10-29 上午10:45:03 
  *
 */
@IocBean
@At("/admin/message")
@Filters( { @By(type = CheckSession.class, args = { "admin", "/admin/loginp.shtml" }) })
public class MessageBackAction {
	@Inject
	protected MessageService messageService;
	
	/**
	 * 获取留言列表
	 * 
	 * @return
	 */
	@At
	@Ok("jsp:jsp.message.showMessageList")	
	//@Filters( { @By(type = CheckSession.class, args = { "master", "/index.jsp" }) })
	public View showMessageList(@Param("type")int type,HttpServletRequest request) {
		messageService.getMessageList(type, request);
		return new JspView("/jsp/back/message/showMessageList");
	}
	
	/**
	 * 增 ： http://localhost:8080/nutztest/jsp/message/showMessageList.shtml
	 */
	@At
	@Ok("redirect:/admin/message/showMessageList.shtml")
	@Aop("validationInterceptor")   
	public Message addMessage(@Param("..") Message ms,HttpServletRequest request,Errors es) {		
		return messageService.addMessage(ms, request, es);
	}
	/**
	 * 审核
	 */
	@At
	@Ok("redirect:/admin/message/showMessageList.shtml")
	public Boolean auditMessage(HttpServletRequest request,Errors es) {
		return messageService.auditMessage(request, es);
	}
}
